home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-05-01 | 8.9 KB | 343 lines | [TEXT/MPS ] |
- // UPrintHandler.cp
- // Copyright © 1985-1991 by Apple Computer, Inc. All rights reserved.
-
-
- #ifndef __STDIO__
- #include <StdIo.h>
- #endif
-
- #ifndef __UGEOMETRY__
- #include <UGeometry.h>
- #endif
-
- #ifndef __BALLOONS__
- #include <Balloons.h>
- #endif
-
- #ifndef __UVIEW__
- #include <UView.h>
- #endif
-
- #ifndef __UFAILURE__
- #include <UFailure.h>
- #endif
-
- #ifndef __UMACAPPUTILITIES__
- #include <UMacAppUtilities.h>
- #endif
-
- #ifndef __UPATCH__
- #include <UPatch.h>
- #endif
-
- #ifndef __DIALOGS__
- #include <Dialogs.h>
- #endif
-
- #ifndef __UMACAPPGLOBALS__
- #include <UMacAppGlobals.h>
- #endif
-
- #ifndef __ERRORS__
- #include <Errors.h>
- #endif
-
- #ifndef __TOOLUTILS__
- #include <ToolUtils.h>
- #endif
-
- #ifndef __UPRINTHANDLER__
- #include <UPrintHandler.h>
- #endif
-
- //--------------------------------------------------------------------------------------------------
- Boolean gFinderPrintingProceed; // proceed with Finder printing
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment PrintOpen
-
- pascal void TPrintMenuBehavior::Initialize(void) // override
- {
- inherited::Initialize();
-
- fPrintHandler = NULL;
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment PrintOpen
-
- pascal void TPrintMenuBehavior::IPrintMenuBehavior(TPrintHandler* itsPrintHandler)
- {
- this->IBehavior();
-
- fPrintHandler = itsPrintHandler;
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment PrintRes
-
- pascal void TPrintMenuBehavior::DoMenuCommand(CmdNumber aCmdNumber)
- {
- // Can print if:
- // • have a print handler, and
- // • print handler has a view, and
- // either • view is not shown (e.g., Finder printing), or
- // • view is active.
- // NOTE: we don't support printing of view's that are shown, but not active.
-
- // This algorithm allows a document to arbitrate between its various TPrintMenuBehavior objects,
- // representing several printable views owned by the document. This arbitration wasn't supported
- // in MacApp prior to version 3.0.
-
- if (fPrintHandler && fPrintHandler->fView && (!fPrintHandler->fView->IsShown() || fPrintHandler->fView->IsActive()))
- {
- if (!fPrintHandler->DoPrintCommand(aCmdNumber)) // if we didn't print, call inherited
- inherited::DoMenuCommand(aCmdNumber);
- }
- else
- inherited::DoMenuCommand(aCmdNumber);
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment PrintRes
-
- pascal void TPrintMenuBehavior::DoSetupMenus()
- {
- inherited::DoSetupMenus();
-
- // see note in TPrintMenuBehavior::DoMenuCommand
- if (fPrintHandler && fPrintHandler->fView && fPrintHandler->fView->IsActive())
- fPrintHandler->DoSetupPrintMenus();
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment PrintOpen
-
- pascal void TPrintHandler::Initialize(void) // override
- {
- inherited::Initialize();
- fDeviceRes = gZeroPt; //!!! Another default?
- fDocument = NULL;
- fFocusedPage = 1;
- fView = NULL;
- fViewPerPage = gZeroVPt; //!!! Another default?
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment PrintOpen
-
- pascal void TPrintHandler::IPrintHandler(TView* itsView)
- {
- this->IViewBehavior(); // attaching to the view is handled by AttachPrintHandler
- fView = itsView;
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MANever
-
- pascal VCoordinate TPrintHandler::BreakFollowing(VHSelect/* vhs */,
- VCoordinate/* prevBreak */,
- Boolean&/* automatic */ )
-
- {
- #if qDebug
- ProgramBreak("BreakFollowing called for non-subclassed Printhandler");
- #endif
-
- return 0;
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAFields
-
- pascal void TPrintHandler::Fields(TObject* obj)
- {
- obj->DoToField("TPrintHandler", NULL, bClass);
- obj->DoToField("fView", &fView, bObject);
- obj->DoToField("fDocument", &fDocument, bObject);
- obj->DoToField("fDeviceRes", &fDeviceRes, bPoint);
- obj->DoToField("fViewPerPage", &fViewPerPage, bVPoint);
- obj->DoToField("fFocusedPage", &fFocusedPage, bInteger);
-
- inherited::Fields(obj);
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MANever
-
- pascal void TPrintHandler::CalcPageStrips(VPoint&)
- {
- #if qDebug
- ProgramBreak("CalcPageStrips called for non-subclassed Printhandler");
- #endif
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MANever
-
- pascal void TPrintHandler::CalcViewPerPage(VPoint&)
- {
- #if qDebug
- ProgramBreak("CalcViewPerPage called for non-subclassed Printhandler");
- #endif
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MANonRes
-
- // See if there are changed printer-configuration parameters which
- // need to be absorbed, and if so, absorb them
- pascal void TPrintHandler::CheckPrinter(void)
- {
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAPrintingRes
-
- //Draw page-breaks, page-numbers, etc.
- pascal void TPrintHandler::DrawPrintFeedback(const VRect& area)
- {
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAPrintingRes
-
- pascal void TPrintHandler::DrawPageBreak(VHSelect vhs,
- long whichBreak,
- VCoordinate loc,
- Boolean automatic)
- {
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAPrintingRes
-
- pascal void TPrintHandler::FocusOnInterior(void)
- {
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAInspector
-
- pascal void TPrintHandler::GetInspectorName(Str255& inspectorName)// override
- {
- Str255 hexString;
-
- if (this == gNullPrintHandler)
- inspectorName = "gNullPrintHandler";
- else if (this == gPrintHandler)
- inspectorName = "gPrintHandler";
- else if (IsObject(fView))
- {
- PointerToHex((long)(fView), hexString, 8);
- inspectorName = "for view " + hexString;
- }
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAPrintingRes
-
- pascal Handle TPrintHandler::GetPrintInfo(void)
- {
- return NULL;
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MANever
-
- pascal void TPrintHandler::LocatePageInterior(long pageNumber,
- VPoint& loc)
- {
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MANever
-
- pascal long TPrintHandler::MaxPageNumber(void)
- {
- return 0;
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAPrint
-
- pascal void TPrintHandler::Print(CmdNumber,
- Boolean& proceed)
- {
- proceed = TRUE;
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MANonRes
-
- pascal void TPrintHandler::PrinterChanged(void)
-
- {
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAFinder
- //??? Signal error ???
-
- pascal Boolean TPrintHandler::SetupForFinder(void)
- {
- #if qDebugMsg
- fprintf(stderr, "SetupForFinder called for a view that can't");
- #endif
-
- return FALSE;
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MANever
-
- pascal void TPrintHandler::RedoPageBreaks(void)
- {
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MANever
-
- pascal void TPrintHandler::Reset(void)
- {
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MANever
-
- pascal Boolean TPrintHandler::DoPrintCommand(CmdNumber /* aCmdNumber */)
- {
- return FALSE;
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MANever
-
- pascal void TPrintHandler::DoSetupPrintMenus()
- {
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment PrintOpen
-
- // Meant to be overridden in a subclass that really prints
- pascal void TPrintHandler::SetDefaultPrintInfo(void)
- {
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MANever
-
- pascal void TPrintHandler::SetPageInterior(long pageNumber)
- {
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MANever
-
- pascal void TPrintHandler::SetPageOffset(const VPoint& coord)
- {
- }
-
-
-